#pragma once
#include<iostream>
#include<pthread.h>
#include<unistd.h>
#include<queue>
#include<stdlib.h>

template<class T>
class Task
{
private:
    T _x;
    T _y;
    char _ch;//判断计算方式,"+-*/%"
public:
    Task()
    {}
    Task(T x, T y, char ch) : _x(x), _y(y),_ch(ch){}
    std::string Show()
    {
        std::string message = std::to_string(_x);
        message += _ch;
        message += std::to_string(_y);
        message += "=?";
        return message;
    }
    int Run()
    {
        int res = 0;
        switch(_ch)
        {
            case '+':
                res = _x + _y;
                break;      
            case '-':
                res = _x - _y;
                break;
            case '*':
                res = _x * _y;
                break;
            case '/':
                res = _x / _y;
                break;
            case '%':
                res = _x % _y;
                break;
        }
        std::cout<<"我是线程["<< pthread_self() <<"]，我完成了一个任务：" << _x << _ch << _y << "=" << res << std::endl;
        return res;
    }

    ~Task()
    {}
};